<template>
	<div>
		<input v-model="msg" type="text">
		<button @click="getimg">图片</button>
		<img :src="imgsrc" alt="">
		
	</div>
</template>


<script>
	import axios from 'axios';
	export default {
		components: {},
		data() {
			return {
				content: '',
				msg: '',
				imgsrc: ''
			}
		},
		mounted() {
			//this.getdata()
		},
		methods: {
			getimg() {
				const self = this; // 将Vue实例的this存储在变量中
				axios({
						method: 'get',
						url: 'http://localhost:5149/api/chat/getimg?msg=' + this.msg,
						onDownloadProgress: (r) => {
							console.log(r.event.target)
							self.imgsrc = 'data:image/png;base64,' + r.event.target.response
						}
					})
					.then(res => {
						console.log(res.data)
						//self.content  = res.data

					}).catch(err => {
						err.data
					})
			},
			getdata() {
				const self = this; // 将Vue实例的this存储在变量中
				axios({
						method: 'get',
						url: 'http://localhost:5149/api/chat/get?msg=用C#写一段冒泡排序"',
						onDownloadProgress: (r) => {
							//console.log(r.event.target.responseText)
							this.content = r.event.target.responseText
						}
					})
					.then(res => {
						console.log(res.data)
						//self.content  = res.data

					}).catch(err => {
						err.data
					})
			}
		}
	}
</script>

<style>
</style>
